package com.etalk.crm.serviceImpl;

import com.alibaba.fastjson.JSON;
import com.etalk.crm.dao.ApiLogMapper;
import com.etalk.crm.pojo.ApiLog;
import com.etalk.crm.service.ApiLogService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 日志上报处理
 *
 * @author Terwer
 * @version 1.0
 * 2019/1/9 13:47
 **/
@Service
public class ApiLogServiceImpl implements ApiLogService {

    @Resource
    private ApiLogMapper apiLogMapper;

    @Transactional
    @Override
    public boolean addApiLog(ApiLog apiLog) {
        String logStr = JSON.toJSONString(apiLog.getLogInfo());
        apiLog.setLogInfoString(logStr);
        int count = apiLogMapper.insertApiLog(apiLog);
        if (count > 0) {
            return true;
        }
        return false;
    }
}
